package com.deimos.tests;

import static org.junit.Assert.*;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.llom.util.AXIOMUtil;
import org.junit.BeforeClass;
import org.junit.Test;
import org.vast.ows.OWSException;
import org.vast.ows.sps.SPSUtils;

import com.deimos.HMA;
import com.deimos.dataBase.TaskController;

public class DescribeTasking {
    private static HMA hma = new HMA();
    SPSUtils utils = new SPSUtils();
    static String taskId = null;

    @BeforeClass
    public static void init() {
	TaskController taskController = new TaskController();
	taskController.createTables(false);
    }

    @Test
    public void describeTasking_Sensor_Exists() throws Exception {
	OMElement request, response;
	request = AXIOMUtil.stringToOM(AllTests.readTest(AllTests.test_dir + "DescribeTasking_Sensor_Exists_Request.xml"));
	response = hma.DescribeTasking(request);
	assertTrue(response.toString().contains("DescribeTaskingResponse"));
    }

    @Test
    public void describeTasking_SensorId_Not_Exists() throws Exception {
	try {
	    OMElement request;
	    request = AXIOMUtil.stringToOM(AllTests.readTest(AllTests.test_dir + "DescribeTasking_SensorId_Not_Found_Request.xml"));
	    hma.DescribeTasking(request);
	    fail();
	} catch (OWSException ex) {
	    assertTrue(ex.getMessage().contains("can not be loaded"));
	}
    }

}
